package com.ysz.component.tableshard.strategy;


import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @ClassName MonthTableShardStrategy
 * @Description 按月分表
 * @Data 14:23
 * @Version 1.0
 * @Author ysz
 */
public class MonthTableShardStrategy implements TableShardStrategy {

    @Override
    public String tableShard(String originalSql, String tableName, long specifyDay) {
        LocalDate now = LocalDate.now();
        return originalSql.replaceAll(tableName, tableName + "-" + now.format(DateTimeFormatter.ofPattern("yyyy-MM")));
    }
}
